
//varying vec3 tnorm;
varying vec3 lvec;
varying vec3 hvec;
varying vec2 texcoord;
uniform sampler2D tex0;
const vec4 diff = vec4(1.0, 0.1, 0.1, 1.0);
const vec4 amb = vec4(0.2, 0.0, 0.0, 1.0);
void main (void) 
{
  vec3 l = normalize(lvec);
  vec3 norm_tex = texture2D(tex0,texcoord).rgb;
  vec3 norm = 2.0*(norm_tex - 0.5);
  norm = normalize (norm);
  float ndl = max(dot(norm,l),0.0);
  vec3 h = normalize(hvec);
  float s = 0.0;
  if(ndl>0.0){
    s = max(dot(h,norm),0.0); 
    s = pow(s,50.0);
  }
  vec4 spec = vec4(1.0,1.0,1.0,1.0) * s;
  gl_FragColor = diff*ndl + spec;
}

